<div class="top-fixed">
    <div class="navbar" style="max-width: 640px;margin: auto;">
        <div class="navbar-inner">
            <div class="left">
                <a href="javascript:history.back();" class=""><i class="fa fa-angle-left" style="font-size: 30px;"></i></a>
            </div>
            <div class="center">代理管理</div>
            <div class="right">
                <a id="allAccountBtn" href="javascript:;" opt-title="全部结算" opt-desc="确认全部代理佣金结算？"
                   class="weui_btn weui_btn_mini weui_btn_warn">全部结算</a>
            </div>
        </div>
    </div>
</div>
<section class="main" style="max-width: 640px;margin: auto;">
    <div id="order-by" class="table bgf tc fs14 order_nav">
        <a href="/partner_agency?order_by=id-desc"
           class="table-cell {{#if_eq query.order_by 'id-desc'}}active{{/if_eq}}">
            <span class="hint-num">倒序</span>
        </a>
        <a href="/partner_agency?order_by=id-asc"
           class="table-cell {{#if_eq query.order_by 'id-asc'}}active{{/if_eq}}">
            <span class="hint-num">正序</span>
        </a>
        <a href="/partner_agency?order_by=amount-desc"
           class="table-cell {{#if_eq query.order_by 'amount-desc'}}active{{/if_eq}}">
            <span class="hint-num">余额</span>
        </a>
        <a href="/partner_agency?order_by=order_count-desc"
           class="table-cell {{#if_eq query.order_by 'order_count-desc'}}active{{/if_eq}}">
            <span class="hint-num">订单</span>
        </a>
        <a href="/partner_agency?order_by=member_count-desc"
           class="table-cell {{#if_eq query.order_by 'member_count-desc'}}active{{/if_eq}}">
            <span class="hint-num">粉丝</span>
        </a>
        <a href="/partner_agency?order_by=agency_count-desc"
           class="table-cell {{#if_eq query.order_by 'agency_count-desc'}}active{{/if_eq}}">
            <span class="hint-num">下级</span>
        </a>
    </div>
    <div class="weui_search_bar" id="search_bar">
        <form class="weui_search_outer" id="search_form" method="get" action="/partner_agency">
            <div class="weui_search_inner">
                <i class="weui_icon_search"></i>
                <input type="search" class="weui_search_input" id="search_input" name="keyword"
                       placeholder="用户编号或用户名搜索"
                       required value="{{query.keyword}}"/>
                <a href="javascript:" class="weui_icon_clear" id="search_clear"></a>
            </div>
            <label for="search_input" class="weui_search_text" id="search_text">
                <i class="weui_icon_search"></i>
                <span>用户编号或用户名搜索</span>
            </label>
        </form>
        <a href="javascript:" class="weui_search_cancel" id="search_cancel">取消</a>
    </div>
    <div class="contact_con fs13">
        {{#if rows}}
            <ul class="list-wrapper">
                {{#each rows}}
                    <li class="bb list-item {{#if data.pending_settle.amount}}NeedSettle{{/if}}">
                        <dl class="table ptb10">
                            <dt class="table-cell vm w70 plr10">
                                <div class="br50 item-pic">
                                    {{#if image}}
                                        <img src="{{image}}?imageView2/1/w/150/h/150/q/75" class="imgm">
                                    {{^}}
                                        <img src="images/default-none-head.png" class="imgm">
                                    {{/if}}
                                </div>
                            </dt>
                            <dd class="table-cell vm">
                                <p class="col3 single-line">{{nickname}} 「ID:{{id}}」</p>
                                {{#if inviter_id}}
                                    <p class="col3 single-line">
                                        <a href="/partner_agency?inviter_id={{inviter_id}}"
                                           class="blue">上级「ID:{{inviter_id}}」</a>
                                    </p>
                                {{/if}}
                                <p class="col6 single-line">{{format_datetime created_at}}</p>
                            </dd>
                            <dt class="table-cell vm item-rt">
                                <span class="tc col9 call">{{level_dict.text}}</span>
                                <p class="col6 single-line">粉丝数({{data.fans_count}})</p>
                                <p class="col6 single-line">下级数({{agency_count}})</p>
                            </dt>
                        </dl>
                        <div class="table tc">
                            <a href="/user_finances?user_id={{id}}" class="table-cell  br">
                                <p class="">余额: <span class="fs18 red bold">{{amount}}</span></p>
                            </a>
                            <a href="/user_finances?user_id={{id}}" class="table-cell  br">
                                <p class="">冻结: <span class="fs18 blue bold">{{frozen}}</span></p>
                            </a>
                            <a href="/partner_orders?user_id={{id}}" class="table-cell br">
                                <p>订单: <span class="fs18 green bold">
                                    {{order_count}}/{{finish_count}}/{{sham_count}}
                                </span></p>
                            </a>
                        </div>
                        {{#if data}}
                            <div class="table index-nav fs12 tc">
                                <a href="javascript:;" class="table-cell  br">
                                    <p class="fs18 red bold">
                                        {{or data.all_amount.amount '0'}}/{{data.all_amount.count}}
                                    </p>
                                    <p>总收入(元/个)</p>
                                    <p class="fs18 red bold">
                                        {{or data.all_amount.inviter_amount '0'}}
                                    </p>
                                </a>
                                <a href="javascript:;" class="table-cell  br">
                                    <p class="fs18 blue bold">
                                        {{or data.pending_settle.amount '0'}}/{{data.pending_settle.count}}
                                    </p>
                                    <p>待结算(元/个)</p>
                                    <p class="fs18 blue bold">
                                        {{or data.pending_settle.inviter_amount '0'}}
                                    </p>
                                </a>
                                <a href="javascript:;" class="table-cell  br">
                                    <p class="fs18 green bold">
                                        {{or data.pending_account.amount '0'}}/{{data.pending_account.count}}
                                    </p>
                                    <p>未入账(元/个)</p>
                                    <p class="fs18 green bold">
                                        {{or data.pending_account.inviter_amount '0'}}
                                    </p>
                                </a>
                            </div>

                            <div class="table">
                                <dd class="table-cell vm p10">
                                    返现:{{order_return_scale}}%
                                </dd>
                                <dd class="table-cell vm p10">
                                    邀请:{{inviter_scale}}%
                                </dd>
                                <dd class="table-cell vm p10">
                                    代理:{{agency_scale}}%
                                </dd>
                                <dd class="table-cell vm p10">
                                    上线:{{inviter_agency_scale}}%
                                </dd>
                            </div>

                            <div class="table index-nav fs12 tc pl10">
                                {{#if tel}}
                                    <div class="table-cell tl">
                                        <p>手机号: <a href="javascript:;" class="clipboard-btn"
                                                   data-clipboard-text="{{tel}}" style="padding: 0px;">{{tel}}</a>
                                        </p>
                                    </div>
                                {{/if}}
                                {{#if qq}}
                                    <div class="table-cell tl">
                                        <p>QQ: <a href="javascript:;" class="clipboard-btn"
                                                  data-clipboard-text="{{qq}}" style="padding: 0px;">{{qq}}</a>
                                        </p>
                                    </div>
                                {{/if}}
                            </div>

                            <div class="table partner-opt" data-id="{{id}}">
                                <dd class="table-cell vm p10">
                                    <a href="javascript:;" opt="account" opt-title="佣金结算" opt-desc="确认佣金结算？"
                                       class="mr5 br3 btn-mini btn-mini_black bgf">佣金结算</a>
                                </dd>
                                <dd class="table-cell vm p10 tc">
                                    <a href="/partner_orders?user_id={{id}}" class="blue ">用户订单</a>
                                </dd>
                                <dd class="table-cell vm p10 tr">
                                    <a href="/partner_orders?agency_id={{id}}" class="blue ">代理订单</a>
                                </dd>
                            </div>
                        {{/if}}
                    </li>
                {{/each}}
            </ul>

            <div class="loadmore-wrapper loadmore" style="margin: 10px;">
                {{#if loadmore}}
                    <div class="weui-infinite-scroll">
                        <div class="infinite-preloader"></div>
                        正在加载...
                    </div>
                {{/if}}
            </div>
        {{^}}
            <div class="tc nothing">
                <span class="mt10 fs14 col9">您还没有代理</span>
            </div>
        {{/if}}
    </div>
</section>